﻿namespace Sidvall.AuthorizationManager.UI.Entities
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
    public sealed partial class AuthorizationScopeResourceItemClaim : global::Sidvall.AuthorizationManager.UI.Entities.Core.BusinessBase, global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim
    {
        #region Business Members

        #region AuthorizationScopeResourceItemClaimId

        private System.Nullable<long> _AuthorizationScopeResourceItemClaimId = null;
        partial void OnBeforeAuthorizationScopeResourceItemClaimIdPropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<long>> eventData);
        partial void OnBeforeAuthorizationScopeResourceItemClaimIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<long>> eventData);
        partial void OnAfterAuthorizationScopeResourceItemClaimIdPropertyChanged();
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        public System.Nullable<long> AuthorizationScopeResourceItemClaimId
        {
            get
            {
                Sidvall.Business.PropertyEventData<System.Nullable<long>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<long>>(_AuthorizationScopeResourceItemClaimId);
                OnBeforeAuthorizationScopeResourceItemClaimIdPropertyGet(eventData);
                return eventData.Value;
            }
            internal set
            {
                Sidvall.Business.PropertyChangeEventData<System.Nullable<long>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<long>>(value, _AuthorizationScopeResourceItemClaimId);
                OnBeforeAuthorizationScopeResourceItemClaimIdPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("AuthorizationScopeResourceItemClaimId", eventData.Value, true, true, true);
                    OnAfterAuthorizationScopeResourceItemClaimIdPropertyChanged();
                }
            }
        }

        #endregion
        #region AuthorizationScopeResourceItemId

        private long _AuthorizationScopeResourceItemId = 0L;
        partial void OnBeforeAuthorizationScopeResourceItemIdPropertyGet(Sidvall.Business.PropertyEventData<long> eventData);
        partial void OnBeforeAuthorizationScopeResourceItemIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<long> eventData);
        partial void OnAfterAuthorizationScopeResourceItemIdPropertyChanged();
        public long AuthorizationScopeResourceItemId
        {
            get
            {
                Sidvall.Business.PropertyEventData<long> eventData = new Sidvall.Business.PropertyEventData<long>(_AuthorizationScopeResourceItemId);
                OnBeforeAuthorizationScopeResourceItemIdPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<long> eventData = new Sidvall.Business.PropertyChangeEventData<long>(value, _AuthorizationScopeResourceItemId);
                OnBeforeAuthorizationScopeResourceItemIdPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("AuthorizationScopeResourceItemId", eventData.Value, true, true, true);
                    OnAfterAuthorizationScopeResourceItemIdPropertyChanged();
                }
            }
        }

        #endregion
        #region ClaimType

        private string _ClaimType = string.Empty;
        partial void OnBeforeClaimTypePropertyGet(Sidvall.Business.PropertyEventData<string> eventData);
        partial void OnBeforeClaimTypePropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterClaimTypePropertyChanged();
        public string ClaimType
        {
            get
            {
                Sidvall.Business.PropertyEventData<string> eventData = new Sidvall.Business.PropertyEventData<string>(_ClaimType);
                OnBeforeClaimTypePropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _ClaimType);
                OnBeforeClaimTypePropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("ClaimType", eventData.Value, true, true, true);
                    OnAfterClaimTypePropertyChanged();
                }
            }
        }

        #endregion
        #region ComparisonOperator

        private global::Sidvall.Data.ComparisonOperator _ComparisonOperator = global::Sidvall.Data.ComparisonOperator.Equal;
        partial void OnBeforeComparisonOperatorPropertyGet(Sidvall.Business.PropertyEventData<global::Sidvall.Data.ComparisonOperator> eventData);
        partial void OnBeforeComparisonOperatorPropertyChanged(Sidvall.Business.PropertyChangeEventData<global::Sidvall.Data.ComparisonOperator> eventData);
        partial void OnAfterComparisonOperatorPropertyChanged();
        public global::Sidvall.Data.ComparisonOperator ComparisonOperator
        {
            get
            {
                Sidvall.Business.PropertyEventData<global::Sidvall.Data.ComparisonOperator> eventData = new Sidvall.Business.PropertyEventData<global::Sidvall.Data.ComparisonOperator>(_ComparisonOperator);
                OnBeforeComparisonOperatorPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<global::Sidvall.Data.ComparisonOperator> eventData = new Sidvall.Business.PropertyChangeEventData<global::Sidvall.Data.ComparisonOperator>(value, _ComparisonOperator);
                OnBeforeComparisonOperatorPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("ComparisonOperator", eventData.Value, true, true, true);
                    OnAfterComparisonOperatorPropertyChanged();
                }
            }
        }

        #endregion
        #region IsEnabled

        private bool _IsEnabled = false;
        partial void OnBeforeIsEnabledPropertyGet(Sidvall.Business.PropertyEventData<bool> eventData);
        partial void OnBeforeIsEnabledPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterIsEnabledPropertyChanged();
        public bool IsEnabled
        {
            get
            {
                Sidvall.Business.PropertyEventData<bool> eventData = new Sidvall.Business.PropertyEventData<bool>(_IsEnabled);
                OnBeforeIsEnabledPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _IsEnabled);
                OnBeforeIsEnabledPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("IsEnabled", eventData.Value, true, true, true);
                    OnAfterIsEnabledPropertyChanged();
                }
            }
        }

        #endregion
        #region Value

        private string _Value = string.Empty;
        partial void OnBeforeValuePropertyGet(Sidvall.Business.PropertyEventData<string> eventData);
        partial void OnBeforeValuePropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterValuePropertyChanged();
        public string Value
        {
            get
            {
                Sidvall.Business.PropertyEventData<string> eventData = new Sidvall.Business.PropertyEventData<string>(_Value);
                OnBeforeValuePropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _Value);
                OnBeforeValuePropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("Value", eventData.Value, true, true, true);
                    OnAfterValuePropertyChanged();
                }
            }
        }

        #endregion
        #region AuthorizationScopeResourceItem

        private AuthorizationScopeResourceItem _AuthorizationScopeResourceItem;
        partial void OnBeforeAuthorizationScopeResourceItemPropertyChanged(Sidvall.Business.PropertyChangeEventData<AuthorizationScopeResourceItem> eventData);
        partial void OnAfterAuthorizationScopeResourceItemPropertyChanged();
        public AuthorizationScopeResourceItem AuthorizationScopeResourceItem
        {
            get
            {
                return _AuthorizationScopeResourceItem;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<AuthorizationScopeResourceItem> eventData = new Sidvall.Business.PropertyChangeEventData<AuthorizationScopeResourceItem>(value, _AuthorizationScopeResourceItem);
                OnBeforeAuthorizationScopeResourceItemPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("AuthorizationScopeResourceItem", eventData.Value, true, true, false);
                    OnAfterAuthorizationScopeResourceItemPropertyChanged();
                }
            }
        }

        #endregion
        #region DataRowContextStorageKey

        protected override string DataRowContextStorageKey
        {
            get
            {
                return global::Sidvall.AuthorizationManager.UI.SystemContext.Current.EntityFacade.AuthorizationScopeResourceItemClaimManager.GetKey(this);
            }
        }

        #endregion
        #region DataRowIsValid

        public override bool DataRowIsValid(Sidvall.Data.BusinessRuleFilter filter)
        {
            return global::Sidvall.AuthorizationManager.UI.SystemContext.Current.EntityFacade.AuthorizationScopeResourceItemClaimManager.DataRowIsValid(this, filter);
        }

        #endregion
        #region DataRowStateIsDirty

        public override bool DataRowStateIsDirty
        {
            get
            {
                return global::Sidvall.AuthorizationManager.UI.SystemContext.Current.EntityFacade.AuthorizationScopeResourceItemClaimManager.DataRowStateIsDirty(this);
            }
        }

        #endregion

        #region LoadAuthorizationScopeResourceItemAsync

        public async System.Threading.Tasks.Task<AuthorizationScopeResourceItem> LoadAuthorizationScopeResourceItemAsync()
        {
            return await LoadAuthorizationScopeResourceItemAsync(false, true, null, null, null);
        }
        public async System.Threading.Tasks.Task<AuthorizationScopeResourceItem> LoadAuthorizationScopeResourceItemAsync(bool refresh, bool raisePropertyChanged, global::Sidvall.Data.FetchCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemField, global::Sidvall.AuthorizationManager.Data.Relations.AuthorizationScopeResourceItemRelation> criteria, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            await global::Sidvall.AuthorizationManager.UI.SystemContext.Current.DataPortal.AuthorizationScopeResourceItemClaimManager.LoadAuthorizationScopeResourceItemAsync(this, refresh, raisePropertyChanged, criteria, strategyContext, objectParameters);

            return this.AuthorizationScopeResourceItem;
        }
        public AuthorizationScopeResourceItem LoadAuthorizationScopeResourceItem(AuthorizationScopeResourceItem item)
        {
            LoadInstanceField("AuthorizationScopeResourceItem", item, true, true, false);
            return item;
        }

        #endregion
        #region LoadInstanceField

        public void LoadInstanceField(string fieldName, object value, bool cascade, bool raisePropertyChanged, bool updateState)
        {
            global::Sidvall.AuthorizationManager.UI.SystemContext.Current.EntityFacade.AuthorizationScopeResourceItemClaimManager.LoadInstanceField(this, fieldName, value, cascade, raisePropertyChanged, updateState);
        }

        #endregion
        #region AcceptChanges

        public void AcceptChanges()
        {
            global::Sidvall.AuthorizationManager.UI.SystemContext.Current.EntityFacade.AuthorizationScopeResourceItemClaimManager.AcceptChanges(this);
        }

        #endregion
        #region Clone

        public AuthorizationScopeResourceItemClaim Clone()
        {
            var copySettings = Sidvall.Data.CopySettings.Clone();
            return Copy(copySettings);
        }

        #endregion
        #region Copy

        public AuthorizationScopeResourceItemClaim Copy()
        {
            return Copy(null);
        }
        public AuthorizationScopeResourceItemClaim Copy(Sidvall.Data.CopySettings copySettings)
        {
            if (copySettings == null)
                copySettings = new Sidvall.Data.CopySettings();
            if (!Sidvall.Data.DataRowContextManager.IsValid(this, copySettings.RowFilter))
                return null;
            var item = new AuthorizationScopeResourceItemClaim();
            Import(item, this, copySettings);
            return item;
        }

        #endregion
        #region Import

        public void Import(global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim item)
        {
            Import(item, null);
        }
        public void Import(global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim item, Sidvall.Data.CopySettings copySettings)
        {
            Import(this, item, copySettings);
        }
        partial void OnAfterImport(AuthorizationScopeResourceItemClaim destination, global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim source, Sidvall.Data.CopySettings copySettings);
        private void Import(AuthorizationScopeResourceItemClaim destination, global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim source, Sidvall.Data.CopySettings copySettings)
        {
            global::Sidvall.AuthorizationManager.UI.SystemContext.Current.EntityFacade.AuthorizationScopeResourceItemClaimManager.Import(destination, source, copySettings);
            OnAfterImport(destination, source, copySettings);
        }
        partial void OnAfterImport(AuthorizationScopeResourceItemClaim destination, AuthorizationScopeResourceItemClaim source, Sidvall.Data.CopySettings copySettings);
        private void Import(AuthorizationScopeResourceItemClaim destination, AuthorizationScopeResourceItemClaim source, Sidvall.Data.CopySettings copySettings)
        {
            Import(destination, source as global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, copySettings);
            OnAfterImport(destination, source, copySettings);
        }

        #endregion
        #region SaveItemAsync

        public async System.Threading.Tasks.Task<AuthorizationScopeResourceItemClaim> SaveItemAsync()
        {
            return await global::Sidvall.AuthorizationManager.UI.SystemContext.Current.DataPortal.AuthorizationScopeResourceItemClaimManager.SaveItemAsync(this);
        }
        public async System.Threading.Tasks.Task<AuthorizationScopeResourceItemClaim> SaveItemAsync(Sidvall.Data.SaveMode mode)
        {
            return await global::Sidvall.AuthorizationManager.UI.SystemContext.Current.DataPortal.AuthorizationScopeResourceItemClaimManager.SaveItemAsync(this, mode);
        }
        public async System.Threading.Tasks.Task<AuthorizationScopeResourceItemClaim> SaveItemAsync(Sidvall.Data.SaveSettings settings)
        {
            return await global::Sidvall.AuthorizationManager.UI.SystemContext.Current.DataPortal.AuthorizationScopeResourceItemClaimManager.SaveItemAsync(this, settings);
        }
        public async System.Threading.Tasks.Task<AuthorizationScopeResourceItemClaim> SaveItemAsync(Sidvall.Data.SaveSettings settings, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            return await global::Sidvall.AuthorizationManager.UI.SystemContext.Current.DataPortal.AuthorizationScopeResourceItemClaimManager.SaveItemAsync(this, settings, strategyContext, objectParameters);
        }

        #endregion
        #region ValidateAsync

        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync()
        {
            return await ValidateAsync((Sidvall.Data.ValidationSettings)null);
        }
        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync(Sidvall.Data.ValidationSettings settings)
        {
            var context = new Sidvall.Business.ValidationContext(settings);
            await global::Sidvall.AuthorizationManager.UI.SystemContext.Current.EntityFacade.AuthorizationScopeResourceItemClaimManager.ValidateAsync(this, context);
            await ValidateAsync(context);
            return context.AllBusinessRules;
        }
        partial void OnAfterValidate(Sidvall.Data.BusinessRuleCollection itemBusinessRules, Sidvall.Business.ValidationContext context);
        public async System.Threading.Tasks.Task ValidateAsync(Sidvall.Business.ValidationContext context)
        {
            var itemBusinessRules = new Sidvall.Data.BusinessRuleCollection();
            OnAfterValidate(itemBusinessRules, context);
            await context.TaskContext.DoTaskAsync();
            context.AllBusinessRules.AddRange(context.Settings.IncludeNotBrokenRules, itemBusinessRules);
            var businessRulesProvider = this as Sidvall.Data.IBusinessRulesProvider;
            if (businessRulesProvider != null)
                businessRulesProvider.BusinessRules.AddRange(context.Settings.IncludeNotBrokenRules, itemBusinessRules);
        }

        #endregion
        #region Initialize

        public void Initialize()
        {
            global::Sidvall.AuthorizationManager.UI.SystemContext.Current.EntityFacade.AuthorizationScopeResourceItemClaimManager.Initialize(this);
        }
        public void Initialize(Sidvall.Data.InitializeSettings settings)
        {
            global::Sidvall.AuthorizationManager.UI.SystemContext.Current.EntityFacade.AuthorizationScopeResourceItemClaimManager.Initialize(this, settings);
        }

        #endregion
        
        #region IAuthorizationScopeResourceItemClaim Members

        System.Nullable<long> global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim.AuthorizationScopeResourceItemClaimId
        {
            get
            {
                return this._AuthorizationScopeResourceItemClaimId;
            }
            set
            {
                this._AuthorizationScopeResourceItemClaimId = value;
            }
        }
        long global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim.AuthorizationScopeResourceItemId
        {
            get
            {
                return this._AuthorizationScopeResourceItemId;
            }
            set
            {
                this._AuthorizationScopeResourceItemId = value;
            }
        }
        string global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim.ClaimType
        {
            get
            {
                return this._ClaimType;
            }
            set
            {
                this._ClaimType = value;
            }
        }
        global::Sidvall.Data.ComparisonOperator global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim.ComparisonOperator
        {
            get
            {
                return this._ComparisonOperator;
            }
            set
            {
                this._ComparisonOperator = value;
            }
        }
        bool global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim.IsEnabled
        {
            get
            {
                return this._IsEnabled;
            }
            set
            {
                this._IsEnabled = value;
            }
        }
        string global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim.Value
        {
            get
            {
                return this._Value;
            }
            set
            {
                this._Value = value;
            }
        }
        global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItem global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim.AuthorizationScopeResourceItem
        {
            get
            {
                return this._AuthorizationScopeResourceItem;
            }
            set
            {
                UpdateChildProperty(this._AuthorizationScopeResourceItem, value);
                this._AuthorizationScopeResourceItem = value as AuthorizationScopeResourceItem;
            }
        }

        #endregion

        #endregion
        #region Constructors

        public AuthorizationScopeResourceItemClaim()
        {
        }

        public AuthorizationScopeResourceItemClaim(Sidvall.Data.DataRowState? dataRowState)
            : base(dataRowState)
        {
        }

        #endregion
    }
}